<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>个人博客搭建部署 | Brennan&#39;s blog</title>
    <meta name="generator" content="VuePress 1.9.5">
    <link rel="icon" href="/brennan-wu-blog/img/favicon.ico">
    <meta name="description" content="web前端技术博客,专注web前端学习与总结。JavaScript,js,ES6,TypeScript,vue,React,python,css3,html5,Node,git,github等技术文章。">
    <meta name="keywords" content="前端博客,个人技术博客,前端,前端开发,前端框架,web前端,前端面试题,技术文档,学习,面试,JavaScript,js,ES6,TypeScript,vue,python,css3,html5,Node,git,github,markdown">
    <meta name="baidu-site-verification" content="7F55weZDDc">
    <meta name="theme-color" content="#11a8cd">
    
    <link rel="preload" href="/brennan-wu-blog/assets/css/0.styles.6d0ebdc8.css" as="style"><link rel="preload" href="/brennan-wu-blog/assets/js/app.422e2e24.js" as="script"><link rel="preload" href="/brennan-wu-blog/assets/js/2.372f0770.js" as="script"><link rel="preload" href="/brennan-wu-blog/assets/js/3.22a0f36b.js" as="script"><link rel="preload" href="/brennan-wu-blog/assets/js/13.ebdfb480.js" as="script"><link rel="prefetch" href="/brennan-wu-blog/assets/js/10.9b0e0932.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/11.389398e0.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/12.c046ebcf.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/14.f75b9d1c.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/15.d20a3fd0.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/16.3816d4a5.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/17.bbbea7a6.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/18.214ef1b5.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/19.0363e8ba.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/20.a38f522d.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/21.6b18ffad.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/22.5c3876be.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/23.dcf195c4.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/24.7e75542f.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/25.9d5b9250.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/26.040652ab.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/27.b3041988.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/28.d5292c46.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/29.7ced233f.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/30.4856fc6c.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/31.0e508fe6.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/32.54efed0e.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/33.89aebe9c.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/34.124399ef.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/35.b1225438.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/36.8909f7ca.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/37.8321b812.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/38.4b637941.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/39.119a3f2c.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/4.28226b98.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/40.9624480f.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/41.df28c0a9.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/42.33d89136.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/43.04ab01ff.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/44.867b4caf.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/45.1337d2e2.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/5.e01b5955.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/6.4fe91b18.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/7.c836dcbd.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/8.85621850.js"><link rel="prefetch" href="/brennan-wu-blog/assets/js/9.5c2abfd9.js">
    <link rel="stylesheet" href="/brennan-wu-blog/assets/css/0.styles.6d0ebdc8.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/brennan-wu-blog/" class="home-link router-link-active"><img src="/brennan-wu-blog/img/logo.png" alt="Brennan's blog" class="logo"> <span class="site-name can-hide">Brennan's blog</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/brennan-wu-blog/" class="nav-link">首页</a></div><div class="nav-item"><a href="/brennan-wu-blog/study/" class="nav-link">学习笔记</a></div><div class="nav-item"><a href="/brennan-wu-blog/grow/" class="nav-link">成长笔记</a></div><div class="nav-item"><a href="/brennan-wu-blog/read/" class="nav-link">读书笔记</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="收藏导航" class="dropdown-title"><a href="/brennan-wu-blog/collection/" class="link-title">收藏导航</a> <span class="title" style="display:none;">收藏导航</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/brennan-wu-blog/pages/527bc4/" class="nav-link">我的导航</a></li><li class="dropdown-item"><!----> <a href="/brennan-wu-blog/pages/c8836a/" class="nav-link">我的收藏</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="索引" class="dropdown-title"><a href="/brennan-wu-blog/archives/" class="link-title">索引</a> <span class="title" style="display:none;">索引</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/brennan-wu-blog/categories/" class="nav-link">分类</a></li><li class="dropdown-item"><!----> <a href="/brennan-wu-blog/tags/" class="nav-link">标签</a></li><li class="dropdown-item"><!----> <a href="/brennan-wu-blog/archives/" class="nav-link">归档</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><div class="blogger"><img src="/brennan-wu-blog/img/logo.png"> <div class="blogger-info"><h3>Brennan Wu</h3> <span>过度忙碌使你落后，有空别忘了给自己充电!</span></div></div> <nav class="nav-links"><div class="nav-item"><a href="/brennan-wu-blog/" class="nav-link">首页</a></div><div class="nav-item"><a href="/brennan-wu-blog/study/" class="nav-link">学习笔记</a></div><div class="nav-item"><a href="/brennan-wu-blog/grow/" class="nav-link">成长笔记</a></div><div class="nav-item"><a href="/brennan-wu-blog/read/" class="nav-link">读书笔记</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="收藏导航" class="dropdown-title"><a href="/brennan-wu-blog/collection/" class="link-title">收藏导航</a> <span class="title" style="display:none;">收藏导航</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/brennan-wu-blog/pages/527bc4/" class="nav-link">我的导航</a></li><li class="dropdown-item"><!----> <a href="/brennan-wu-blog/pages/c8836a/" class="nav-link">我的收藏</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="索引" class="dropdown-title"><a href="/brennan-wu-blog/archives/" class="link-title">索引</a> <span class="title" style="display:none;">索引</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/brennan-wu-blog/categories/" class="nav-link">分类</a></li><li class="dropdown-item"><!----> <a href="/brennan-wu-blog/tags/" class="nav-link">标签</a></li><li class="dropdown-item"><!----> <a href="/brennan-wu-blog/archives/" class="nav-link">归档</a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>JavaScript</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Vue.js</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>Git</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/brennan-wu-blog/pages/637e61/" aria-current="page" class="active sidebar-link">个人博客搭建部署</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level2"><a href="/brennan-wu-blog/pages/637e61/#github-actions" class="sidebar-link">GitHub Actions</a></li><li class="sidebar-sub-header level2"><a href="/brennan-wu-blog/pages/637e61/#github-actions配置" class="sidebar-link">GitHub Actions配置</a></li><li class="sidebar-sub-header level2"><a href="/brennan-wu-blog/pages/637e61/#配置actions" class="sidebar-link">配置Actions</a></li><li class="sidebar-sub-header level2"><a href="/brennan-wu-blog/pages/637e61/#配置-deploy-key" class="sidebar-link">配置 deploy_key</a></li></ul></li><li><a href="/brennan-wu-blog/pages/eb4829/" class="sidebar-link">个人常用Git命令指南</a></li></ul></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-5712e8f9><div class="articleInfo" data-v-5712e8f9><ul class="breadcrumbs" data-v-5712e8f9><li data-v-5712e8f9><a href="/brennan-wu-blog/" title="首页" class="iconfont icon-home router-link-active" data-v-5712e8f9></a></li> <li data-v-5712e8f9><a href="/brennan-wu-blog/study/#学习笔记" data-v-5712e8f9>学习笔记</a></li><li data-v-5712e8f9><a href="/brennan-wu-blog/study/#Git" data-v-5712e8f9>Git</a></li></ul> <div class="info" data-v-5712e8f9><div title="作者" class="author iconfont icon-geren" data-v-5712e8f9><a href="https://github.com/wyd112821" target="_blank" title="作者" class="beLink" data-v-5712e8f9>Brennan Wu</a></div> <div title="创建时间" class="date iconfont icon-rili" data-v-5712e8f9><a href="javascript:;" data-v-5712e8f9>2022-09-28</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">个人博客搭建部署<!----></h1> <!----> <div class="theme-vdoing-content content__default"><h1 id="个人博客搭建部署"><a href="#个人博客搭建部署" class="header-anchor">#</a> 个人博客搭建部署</h1> <div class="custom-block note"><p class="custom-block-title">前言</p> <p>当我们使用vuepress搭建好属于自己风格的博客，我们需要重新打包并放在GitHub或者自己的私服上，但是当我们一旦更新博客，我们便需要重新打包上传，这般繁琐并不适合常态化的更新博客，于是便有了将打包，上传，部署进行自动化的需求,同时GitHub访问速度缓慢，同步并部署至Gitee上，以保证国内访问速度。</p></div> <h2 id="github-actions"><a href="#github-actions" class="header-anchor">#</a> GitHub Actions</h2> <p>GitHub Actions 是 GitHub 的持续集成服务，于2018年10月推出。官方还推出了相关插件库市场，可以直接使用他人写好的插件，如果你想详细了解GitHub Actions 请参考阮一峰老师的博客<a href="http://www.ruanyifeng.com/blog/2019/09/getting-started-with-github-actions.html" target="_blank" rel="noopener noreferrer">GitHub Actions入门<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p>使用Github Actions我们可以实现：</p> <ul><li>监听git push 自动打包</li> <li>分离博客源码和打包后代码</li> <li>自动部署发布</li></ul> <p>简单来说，它的作用便是，当我们将新博客push到仓库中，后续的打包发布都不需要我们去管，其次，为了更方便对博客文章进行管理，我将博客源码（私有）和部署博客（公开）分别放在两个仓库中。接下来便是实现方式。</p> <h2 id="github-actions配置"><a href="#github-actions配置" class="header-anchor">#</a> GitHub Actions配置</h2> <p>在博客源码仓库中，选择Actions,点击Set up this workflow;</p> <p><img src="https://cdn.staticaly.com/gh/wyd112821/Blogger@master/static_files/img/xxx.4irlxmgxnq0w.webp" alt="img"></p> <h2 id="配置actions"><a href="#配置actions" class="header-anchor">#</a> 配置Actions</h2> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">name</span><span class="token punctuation">:</span> Automatic blog update <span class="token comment"># 该Action的名字</span>

<span class="token comment"># on:何时触发该事件. </span>
<span class="token key atrule">on</span><span class="token punctuation">:</span>
  <span class="token comment"># 在push或pull请求事件时触发工作流，但只针对主分支</span>
  <span class="token key atrule">push</span><span class="token punctuation">:</span>
    <span class="token key atrule">branches</span><span class="token punctuation">:</span> <span class="token punctuation">[</span> master <span class="token punctuation">]</span>
  <span class="token key atrule">pull_request</span><span class="token punctuation">:</span>
    <span class="token key atrule">branches</span><span class="token punctuation">:</span> <span class="token punctuation">[</span> master <span class="token punctuation">]</span>

  <span class="token comment"># 允许从Actions选项卡手动运行此工作流</span>
  <span class="token key atrule">workflow_dispatch</span><span class="token punctuation">:</span>

<span class="token comment"># 工作流运行由一个或多个jobs组成，这些job可以按顺序或并行运行</span>
<span class="token key atrule">jobs</span><span class="token punctuation">:</span>
  <span class="token comment"># 此工作流包含一个名为“build-deploy”的job。</span>
  <span class="token key atrule">build-deploy</span><span class="token punctuation">:</span>
    <span class="token comment"># 改job运行于什么虚拟机上</span>
    <span class="token key atrule">runs-on</span><span class="token punctuation">:</span> Ubuntu<span class="token punctuation">-</span><span class="token number">20.04</span>

    <span class="token comment"># steps表示将作为job一部分执行的一系列任务</span>
    <span class="token key atrule">steps</span><span class="token punctuation">:</span>
      <span class="token punctuation">-</span> <span class="token key atrule">uses</span><span class="token punctuation">:</span> actions/checkout@master <span class="token comment"># 切换分支到master</span>
        <span class="token key atrule">with</span><span class="token punctuation">:</span>
         <span class="token key atrule">fetch-depth</span><span class="token punctuation">:</span> <span class="token number">2</span> 
      <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Use Node.js 12.x  <span class="token comment">#使用nodejs 12.x版本</span>
        <span class="token key atrule">uses</span><span class="token punctuation">:</span> actions/setup<span class="token punctuation">-</span>node@v1
        <span class="token key atrule">with</span><span class="token punctuation">:</span>
          <span class="token key atrule">node-version</span><span class="token punctuation">:</span> <span class="token string">'12.x'</span>

      <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> install and build
        <span class="token key atrule">run</span><span class="token punctuation">:</span> npm install <span class="token important">&amp;&amp;</span> npm run build

      <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> deploy <span class="token comment">#部署至GitHub</span>
        <span class="token key atrule">uses</span><span class="token punctuation">:</span> peaceiris/actions<span class="token punctuation">-</span>gh<span class="token punctuation">-</span>pages@v3 <span class="token comment">#和上面一样，这里使用的是他人写好的插件库，作用是发布到其他仓库中或者其他分支上，想要具体了解可以在插件库中搜索</span>
        <span class="token key atrule">with</span><span class="token punctuation">:</span>
          <span class="token key atrule">deploy_key</span><span class="token punctuation">:</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span> secrets.BLOG <span class="token punctuation">}</span><span class="token punctuation">}</span> <span class="token comment"># key</span>
          <span class="token key atrule">external_repository</span><span class="token punctuation">:</span> wyd112821/Brennan<span class="token punctuation">-</span>Wu<span class="token punctuation">-</span>Blog <span class="token comment">#推送到该仓库中，地址格式为github名称/仓库名</span>
          <span class="token key atrule">publish_branch</span><span class="token punctuation">:</span> master <span class="token comment">#分支名</span>
          <span class="token key atrule">publish_dir</span><span class="token punctuation">:</span> docs/.vuepress/dist <span class="token comment">#要推送的内容（打包后的博客文件夹）</span>

      <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Sync to Gitee <span class="token comment"># 同步到Gitee</span>
        <span class="token key atrule">uses</span><span class="token punctuation">:</span> wearerequired/git<span class="token punctuation">-</span>mirror<span class="token punctuation">-</span>action@d5724af3876c8fdfdb59312c99df0d11b769ca8c
        <span class="token key atrule">env</span><span class="token punctuation">:</span>
          <span class="token comment"># 注意在 Settings-&gt;Secrets 配置 GITEE_RSA_PRIVATE_KEY</span>
          <span class="token key atrule">SSH_PRIVATE_KEY</span><span class="token punctuation">:</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span> secrets.BLOG <span class="token punctuation">}</span><span class="token punctuation">}</span>
        <span class="token key atrule">with</span><span class="token punctuation">:</span>
          <span class="token comment"># 注意替换为你的 GitHub 公开仓库地址</span>
          <span class="token key atrule">source-repo</span><span class="token punctuation">:</span> git@github.com<span class="token punctuation">:</span>wyd112821/Brennan<span class="token punctuation">-</span>Wu<span class="token punctuation">-</span>Blog.git
          <span class="token comment"># 注意替换为你的 Gitee 目标仓库地址</span>
          <span class="token key atrule">destination-repo</span><span class="token punctuation">:</span> git@gitee.com<span class="token punctuation">:</span>wuyadong112821/brennan<span class="token punctuation">-</span>wu<span class="token punctuation">-</span>blog.git
      <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> deploy2 <span class="token comment">#部署到gitee</span>
        <span class="token key atrule">uses</span><span class="token punctuation">:</span> yanglbme/gitee<span class="token punctuation">-</span>pages<span class="token punctuation">-</span>action@v1.3.2
        <span class="token key atrule">with</span><span class="token punctuation">:</span>
          <span class="token key atrule">deploy_key</span><span class="token punctuation">:</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span> secrets.BLOG <span class="token punctuation">}</span><span class="token punctuation">}</span> <span class="token comment"># key</span>
          <span class="token key atrule">gitee-username</span><span class="token punctuation">:</span> wuyadong112821
          <span class="token key atrule">gitee-password</span><span class="token punctuation">:</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span> secrets.GITEE <span class="token punctuation">}</span><span class="token punctuation">}</span> 
          <span class="token key atrule">gitee-repo</span><span class="token punctuation">:</span> wuyadong112821/brennan<span class="token punctuation">-</span>wu<span class="token punctuation">-</span>blog <span class="token comment">#推送到该仓库中，地址格式为gitee名称/仓库名</span>
          <span class="token key atrule">branch</span><span class="token punctuation">:</span> master <span class="token comment">#分支名</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br></div></div><p>配置好之后commit即可。</p> <h2 id="配置-deploy-key"><a href="#配置-deploy-key" class="header-anchor">#</a> 配置 deploy_key</h2> <p>配置过程中容易出错的便是deploy_key的配置,设置deploy_key的目的是获取push权限，并且不被其他人所见。</p> <p>如何设置deploy_key？</p> <ul><li><p>在cmd中执行 ssh-keygen -t rsa -C yourname@youremail.com</p></li> <li><p>生成了两个文件 xx(私有) 和 xx.pub(公有)</p></li> <li><p>打开部署博客（公开）的仓库的Settings &gt; Deploy_keys &gt; Add depoly_key</p></li></ul> <p><img src="https://cdn.staticaly.com/gh/wyd112821/Blogger@master/static_files/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_0002.3aywl40k91c0.webp" alt="微信截图_0002"></p> <ul><li>为了方便分辩，我将名称设置为BLOG,再将xx.pub(公有)的内容复制到文本框中，勾选Allow write access(写入权限)最后选择Add Key</li></ul> <p><img src="https://cdn.staticaly.com/gh/wyd112821/Blogger@master/static_files/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_0003.1o70fsujrxvk.webp" alt="微信截图_0003"></p> <ul><li>打开博客源码所在仓库的Settings,选择Secrets,与添加Deploy_key相仿，选择添加新的Secret，添加名称（建议与deploy_key相同），将xx(私有)的内容复制到文本框，最后选择Add Secret;</li></ul> <p><img src="https://cdn.staticaly.com/gh/wyd112821/Blogger@master/static_files/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_0004.7dz8w195q074.webp" alt="微信截图_0004"></p> <ul><li><p>初始化Gitee博客仓库，创建时，可以顺便把GitHub仓库的代码拉下来，然后选择 服务&gt;Gitee Pages 配置一下博客并启动；</p></li> <li><p>在Gitee中，点击右上角头像 &gt; 设置 &gt; SSH公钥，同GitHub上一样，设置一个ssh key，这里推荐使用同一个key（BLOG)</p></li></ul> <p><img src="https://cdn.staticaly.com/gh/wyd112821/Blogger@master/static_files/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_0005.6wts1sym3ugw.webp" alt="微信截图_0005"></p> <ul><li>在Gitee中，点击右上角头像 &gt; 设置，进行第三方账号绑定，将微信绑定；</li></ul> <p><img src="https://cdn.staticaly.com/gh/wyd112821/Blogger@master/static_files/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_0006.1blomcu3gj5s.webp" alt="微信截图_0006"></p> <ul><li>在Github源代码仓库 Settings &gt; Secrets 中设置了BlOG变量，这一次再增加GITEE变量，变量内容为Gitee的密码。</li></ul> <p><img src="https://cdn.staticaly.com/gh/wyd112821/Blogger@master/static_files/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20220928191531.32nkootbcxj4.webp" alt="微信截图_20220928191531"></p> <div class="custom-block note"><p class="custom-block-title">总结</p> <p>至此，我前面提到的需求就实现啦，只需要把源码push到github仓库这一个步骤，后面的博客打包、部署到github和gitee等工作都由GitHub Actions来自动完成。</p> <p>如下你想查看部署日志，你可以到github仓库的Actions这一项查看。</p></div></div></div> <!----> <div class="page-edit"><!----> <!----> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2023/04/26, 07:29:08</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/brennan-wu-blog/pages/c86754/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">Nuxt爬坑指南</div></a> <a href="/brennan-wu-blog/pages/eb4829/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">个人常用Git命令指南</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/brennan-wu-blog/pages/c86754/" class="prev">Nuxt爬坑指南</a></span> <span class="next"><a href="/brennan-wu-blog/pages/eb4829/">个人常用Git命令指南</a>→
      </span></p></div></div></div> <div class="article-list"><div class="article-title"><a href="/brennan-wu-blog/archives/" class="iconfont icon-bi">最近更新</a></div> <div class="article-wrapper"><dl><dd>01</dd> <dt><a href="/brennan-wu-blog/pages/8a0173/"><div>
            职业路线：前端工程师的晋升逻辑到底是什么
            <!----></div></a> <span class="date">05-02</span></dt></dl><dl><dd>02</dd> <dt><a href="/brennan-wu-blog/pages/c002a8/"><div>
            《从技术走向管理：李元芳履职记》读书笔记
            <!----></div></a> <span class="date">04-15</span></dt></dl><dl><dd>03</dd> <dt><a href="/brennan-wu-blog/pages/2641af/"><div>
            解读《真希望我父母读过这本书》
            <!----></div></a> <span class="date">11-28</span></dt></dl> <dl><dd></dd> <dt><a href="/brennan-wu-blog/archives/" class="more">更多文章&gt;</a></dt></dl></div></div></main></div> <div class="footer"><div class="icons"><a href="mailto:985979261@qq.com" title="发邮件" target="_blank" class="iconfont icon-juchangxinxiang"></a><a href="https://github.com/wyd112821" title="GitHub" target="_blank" class="iconfont icon-github"></a><a href="https://gitee.com/wuyadong112821" title="gitee" target="_blank" class="iconfont icon-gitee"></a></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2022-2023
    <span>Brennan Wu | <a href="https://github.com/xugaoyi/vuepress-theme-vdoing/blob/master/LICENSE" target="_blank">MIT License</a></span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-262" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-43_zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"></div></div>
    <script src="/brennan-wu-blog/assets/js/app.422e2e24.js" defer></script><script src="/brennan-wu-blog/assets/js/2.372f0770.js" defer></script><script src="/brennan-wu-blog/assets/js/3.22a0f36b.js" defer></script><script src="/brennan-wu-blog/assets/js/13.ebdfb480.js" defer></script>
  </body>
</html>
